package org.kzwl.book.controller.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.AdminQueryCuVolunteersBO;
import org.kzwl.comm.pojo.bo.CuVolunteersSignDTO;
import org.kzwl.comm.pojo.bo.SaveCuVolunteersBO;
import org.kzwl.comm.pojo.bo.volunteers.RegisterVolunteersBO;
import org.kzwl.comm.pojo.bo.volunteers.VolunteersBasicBO;
import org.kzwl.comm.pojo.bo.volunteers.VolunteersSignBO;
import org.kzwl.comm.pojo.dto.volunteers.QueryDetailsDTO;
import org.kzwl.comm.pojo.dto.volunteers.VolunteersDTO;
import org.kzwl.entity.app.CuVolunteersUser;
import org.kzwl.entity.web.CuVolunteers;
import org.kzwl.service.web.CuVolunteersService;
import org.kzwl.service.web.CuVolunteersUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-12-17
 */
@Api( "志愿者服务")
@RestController
@RequestMapping("/cu-volunteers")
public class CuVolunteersController {

    @Autowired
    CuVolunteersService cuVolunteersService;
    @Autowired
    CuVolunteersUserService cuVolunteersUserService;



    /**
    * @Author:maomao
    * @Description: 查询参加活动的人员
    * @Date: 2021/3/8 8:11 下午
    */
    @PostMapping("/queryCuVolunteersSignUser")
    public ResponseData<List<CuVolunteersSignDTO>> queryCuVolunteersSignUser(@RequestBody Integer cuVolunteersId)
    {
        return cuVolunteersUserService.queryCuVolunteersSignUser(cuVolunteersId);
    }


    @ApiOperation(value = "admin_PC添加一条 志愿者信息")
    @PostMapping("/saveOne")
    public ResponseData<Void> saveOne(@RequestBody  @Valid SaveCuVolunteersBO saveCuVolunteersBO)
    {
        return cuVolunteersService.saveOne(saveCuVolunteersBO);
    }
    @ApiOperation(value = "admin_PC查询志愿信息")
    @PostMapping("/queryPage")
    public ResponseData<IPage<CuVolunteers>> queryPage(@RequestBody AdminQueryCuVolunteersBO adminQueryCuVolunteersBO)
    {
        return cuVolunteersService.queryPage(adminQueryCuVolunteersBO);
    }

    @ApiOperation(value = "admin_PC修改一条志愿者信息")
    @PostMapping("/updateOne")
    public ResponseData<Void> updateOne(@RequestBody SaveCuVolunteersBO saveCuVolunteersBO)
    {
        return cuVolunteersService.updateOne(saveCuVolunteersBO);
    }
    @ApiOperation(value = "admin_PC删除一条志愿者信息")
    @PostMapping("/deleteId")
    public ResponseData<Void> deleteId(@RequestBody Long Id)
    {
        return cuVolunteersService.deleteId(Id);
    }

    @ApiOperation(value = "admin_PC查询一条志愿者信息")
    @PostMapping("/queryId")
    public ResponseData<CuVolunteers> queryId(@RequestBody Long Id)
    {
        return cuVolunteersService.queryId(Id);
    }

    @ApiOperation(value = "志愿者信息基础查询")
    @PostMapping("/queryBasic")
    public ResponseData<IPage<VolunteersDTO>> queryBasic(@RequestBody VolunteersBasicBO bo)
    {
        IPage<VolunteersDTO> page = cuVolunteersService.queryBasic(bo);
        return new ResponseData<>(page);
    }

    @ApiOperation(value = "志愿者信息查询详细")
    @PostMapping("/queryDetails")
    public ResponseData<QueryDetailsDTO> queryDetails(@RequestBody VolunteersBasicBO bo)
    {
        QueryDetailsDTO dto = cuVolunteersService.queryDetails(bo);
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "注册成为志愿者")
    @PostMapping("/registerVolunteers")
    public ResponseData<Void> registerVolunteers(@RequestBody RegisterVolunteersBO bo)
    {
         cuVolunteersService.registerVolunteers(bo);
        return new ResponseData<>();
    }

    @ApiOperation(value = "服务报名")
    @PostMapping("/volunteersSign")
    public ResponseData<Void> volunteersSign(@RequestBody VolunteersSignBO bo)
    {
        cuVolunteersService.volunteersSign(bo);
        return new ResponseData<>();
    }

    @ApiOperation(value = "志愿者注册人数")
    @PostMapping("/volunteersCount")
    public ResponseData<Integer> volunteersCount()
    {
        int count = cuVolunteersService.volunteersCount();
        return new ResponseData<>(count);
    }

}
